package com.umeox.calculator;

import android.content.Context;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

import androidx.appcompat.widget.AppCompatButton;


public class ColorButton extends AppCompatButton implements View.OnClickListener {
    OnClickListener mListener;
    float mTextX;
    float mTextY;

    public ColorButton(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.mListener = ((Calculator) context).mListener;
        setOnClickListener(this);
    }

    public void onClick(View view) {
        this.mListener.onClick(this);
    }

    public void onSizeChanged(int w, int h, int oldW, int oldH) {
        measureText();
    }

    private void measureText() {
        Paint paint = getPaint();
        this.mTextX = (((float) getWidth()) - paint.measureText(getText().toString())) / 2.0f;
        this.mTextY = ((((float) getHeight()) - paint.ascent()) - paint.descent()) / 2.0f;
    }

    /* access modifiers changed from: protected */
    public void onTextChanged(CharSequence text, int start, int before, int after) {
        measureText();
    }
}
